// pages/user/index/index.js
const config = getApp().globalData.config
const T = getApp().globalData.T
let token = ''
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      role: getApp().globalData.role
    });    
    console.warn('role:' + getApp().globalData.role);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {
    this.setData({
      platform: getApp().globalData.platform
    });
    console.log(this.data.platform);
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    token = getApp().globalData.token;
    this.getDetail();
  },

  getDetail() {
    T.req({
      url: config.api + 'center/userinfo',
      method: 'GET',
      data: {
        token: token
      },
      success: (res) => {
        getApp().globalData.userInfo.companyId = res.companyId
        this.setData({
          obj: res
        })
      }
    })

  },

  onEditCompanyInfo(e) {
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/login/company/company?origin=edit',
    })
  },

  onEditAdminInfo() {
    wx.navigateTo({
      url: '/pages/login/base-info/info?origin=edit',
    })
  }

})